using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_SkillHurt : MonoBehaviour
{
    public enum skillhurt
    {
        skill1,
        skill2,
        huhunlei,
        suiyujue,
    }

    public skillhurt Hurt;
    public float TrapMagicTime = 0.2f;
    public float ContinuousMagicTime = 4f;

    public bool skill2 = false;

    private bool hasCollided = false;
    public GameObject player;
    public Player_Buff Player_Buff;


    // Start is called before the first frame update
    void Start()
    {
 
           Collider collider = GetComponent<Collider>();
           Destroy(collider, TrapMagicTime);
           Destroy(gameObject, 2f);
        player = GameObject.Find("Player").transform.gameObject;
        Player_Buff = GameObject.Find("Player").GetComponent<Player_Buff>();

    }

    void Update()
    {

    }
    // Update is called once per frame
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Enemy")
        {
           
            if (!hasCollided&&gameObject.tag=="PlaySkill1")
            {
                other.gameObject.GetComponent<Enemy_GetHurt>().GetHurt(player.GetComponent<Player_Control>().Atk_1 * 5);
            }
            else if (!hasCollided && gameObject.tag == "PlaySkill2")
            {
                other.gameObject.GetComponent<Enemy_GetHurt>().GetHurt(player.GetComponent<Player_Control>().Atk_2 * 2.5f);

            }
            else if(Hurt==skillhurt.huhunlei)
            {
                other.gameObject.GetComponent<Enemy_GetHurt>().GetHurt(player.GetComponent<Player_Control>().Atk_1 *(1+((Player_Buff.Huhunlei_Level-1)*0.25f)));
            }
            else if (Hurt == skillhurt.suiyujue)
            {
                other.gameObject.GetComponent<Enemy_GetHurt>().GetHurt(player.GetComponent<Player_Control>().Atk_1 * (2.5f + ((Player_Buff.SuiYuJue_Level-1)* 0.5f)));
            }

        }

    }
}
